<template>
  <div class="allOrderContainer">
    <!-- 头部搜索部分 -->
    <div id="download" style="width: 100%"></div>
    <div class="actions">
      <div class="left" style="margin-bottom: 10px">
        <el-button
          id="waybill_create_icon"
          type="primary"
          plain
          size="mini"
          @click="WaybillClickFn"
          data-tracker="P3-3"
          v-permission="'waybill_create'"
          >创建运单</el-button
        >
        <el-button
          id="waybill_edit_icon"
          type="primary"
          plain
          size="mini"
          @click="clickEditPropFn"
          data-tracker="P3-4"
          v-permission="'waybill_update'"
          >编辑运单</el-button
        >
        <el-button
          id="waybill_del_icon"
          v-permission="'waybill'"
          type="primary"
          plain
          size="mini"
          @click="ClickDeleteFn"
          data-tracker="P3-5"
          :loading="deleteLoading"
          >删除运单</el-button
        >

        <el-button
          v-permission="'waybill_export'"
          type="primary"
          plain
          size="mini"
          @click="ExportOrders"
          :loading="loadingfalse"
          data-tracker="P3-33"
          >导出</el-button
        >

        <el-dropdown
          v-permission="'waybill_detail'"
          @command="handleWaybill"
          divided
          v-if="isDushi && isHavePermission('order_detail')"
          class="operation-drop"
        >
          <el-button type="primary" plain>
            运单操作<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu
            class="operation-drop"
            slot="dropdown"
            style="width: 150px"
          >
            <!-- <el-dropdown-item command="0">导入 </el-dropdown-item>
            <el-dropdown-item command="1">导出 </el-dropdown-item>
            <el-dropdown-item command="4">拆单 </el-dropdown-item>
            <el-dropdown-item command="5">合单</el-dropdown-item> -->
            <el-dropdown-item command="2">打印标签 </el-dropdown-item>
            <el-dropdown-item command="3">打印运单(标准) </el-dropdown-item>
            <el-dropdown-item command="6">打印运单(通用) </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <el-dropdown
          @command="handleWaybillMessage"
          divided
          class="operation-drop"
          v-permission="[
            'waybill_import_update',
            'waybillCollect_import_update',
            'dispatch_import_update',
            'waybillDistribution_import_update',
            'waybillReceipt_import_update',
            'waybill_box_recyle_import_update',
          ]"
        >
          <el-button type="primary" plain>
            导入<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu
            class="operation-drop"
            slot="dropdown"
            style="width: 150px"
          >
            <el-dropdown-item command="1" v-permission="'waybill_import_update'"
              >修改运单信息</el-dropdown-item
            >
            <el-dropdown-item
              command="2"
              v-permission="'waybillCollect_import_update'"
              >修改揽收单信息</el-dropdown-item
            >
            <el-dropdown-item
              command="3"
              v-permission="'dispatch_import_update'"
              >修改干线单信息</el-dropdown-item
            >
            <el-dropdown-item
              command="4"
              v-permission="'waybillDistribution_import_update'"
              >修改配送单信息</el-dropdown-item
            >
            <el-dropdown-item
              command="5"
              v-permission="'waybillReceipt_import_update'"
              >修改回单信息</el-dropdown-item
            >
            <el-dropdown-item
              command="6"
              v-permission="'waybill_box_recyle_import_update'"
              >修改回箱信息</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>
        <el-dropdown
          v-permission="[
            'waybill_collect_create',
            'dispatch_create',
            'waybillDistribution_create',
            'waybillSign_create',
            'waybill_receipt_create',
            'waybill_box_recyle_create',
          ]"
          @command="handleCommand"
          divided
          class="operation-drop"
        >
          <el-button type="primary" plain>
            批量操作<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu class="operation-drop" slot="dropdown">
            <el-dropdown-item
              v-permission="
                item.value === '揽收'
                  ? 'waybill_collect_create'
                  : item.value === '配送'
                  ? 'waybillDistribution_create'
                  : item.value === '回单'
                  ? 'waybill_receipt_create'
                  : item.value === '回箱'
                  ? 'waybill_box_recyle_create'
                  : item.value === '干线'
                  ? 'dispatch_create'
                  : item.value === '签收'
                  ? 'waybillSign_create'
                  : ''
              "
              :key="item.id"
              :command="item.id"
              v-for="item in steps"
              >{{ item.value }}
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <el-dropdown
          v-permission="'waybill_data_print'"
          @command="selectPrintPage"
          divided
          class="operation-drop"
          @visible-change="handlePrint"
        >
          <el-button type="primary" plain>
            批量打印<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu
            class="operation-drop"
            slot="dropdown"
            style="width: 150px"
          >
            <el-dropdown-item
              :key="item.id"
              :command="item.id"
              v-for="item in printPageList"
              >{{ item.template_data.template_name }}
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <el-dialog
          class="dialogTable"
          title="填写包装数量"
          :visible.sync="dialogTableVisible"
          width="600px"
        >
          <el-table :data="multipleSelection">
            <el-table-column
              property="waybill_no"
              label="运单号"
              width="150"
            ></el-table-column>
            <el-table-column
              property="receiver_company"
              label="收货公司"
              width="250"
            ></el-table-column>
            <el-table-column
              property="total_package_quantity"
              label="包装数量"
              width="150"
            >
              <template slot-scope="scope">
                <el-input v-model="scope.row.total_package_quantity"></el-input>
              </template>
            </el-table-column>
          </el-table>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogTableVisible = false">取 消</el-button>
            <el-button type="primary" @click="submitPackageNum"
              >确 认</el-button
            >
          </span>
        </el-dialog>
        <el-dialog
          title="打印标签"
          :visible.sync="dialogLabelVisible"
          width="500px"
          :before-close="handleClose"
          :close-on-click-modal="false"
        >
          <div class="qianzhi_content" id="printMe">
            <div class="qianzhi_top">
              <div class="top_left">
                <img :src="logo" />
                渡石医药
              </div>
              <div class="top_right" style="margin-left: -10px">
                <span
                  >{{
                    selectedDetail.goods
                      ? selectedDetail.goods.reduce((item1, item2) => {
                          return item1 + item2.number * 1;
                        }, 0)
                      : ""
                  }}
                  — {{ numberItem }}</span
                >
                <i>{{
                  selectedDetail
                    ? new Date(Number(selectedDetail.create_time) * 1000)
                        .toLocaleString()
                        .replace(/:\d{1,2}$/, " ")
                    : ""
                }}</i>
              </div>
            </div>
            <div class="qianzhi_tm">
              <div style="height: 60px; margin-left: 5px">
                <canvas id="canvas"></canvas>
              </div>
              <div
                style="
                  font-size: 16px;
                  letter-spacing: 11px;
                  margin-top: -10px;
                  margin-left: 15px;
                "
              >
                {{ selectedDetail ? selectedDetail.waybill_number : "" }}-{{
                  numberItem
                }}
              </div>
            </div>
            <div class="qianzhi_address">
              <span class="span1">目的地</span>
              <span
                >{{ selectedDetail ? selectedDetail.from_region : "" }}
                -
                {{ selectedDetail ? selectedDetail.to_region : "" }}</span
              >
            </div>
            <div class="qianzhi_sjr">
              <span class="span2">收件人</span>
              <span style="width: 378px">
                <i>{{
                  selectedDetail.receiver ? selectedDetail.receiver.name : ""
                }}</i>
                <i>{{
                  selectedDetail.receiver ? selectedDetail.receiver.address : ""
                }}</i>
                <i>{{
                  selectedDetail.receiver ? selectedDetail.receiver.phone : ""
                }}</i>
              </span>
            </div>
            <div class="shangj_code">
              <span class="span1"
                >温区：<i>{{ thermosphereData }}</i></span
              >
              <span
                >共<i>{{
                  selectedDetail.goods
                    ? selectedDetail.goods.reduce((item1, item2) => {
                        return item1 + item2.number * 1;
                      }, 0)
                    : ""
                }}</i
                >件</span
              >
              <span
                >当前第<i>{{ numberItem }}</i
                >件</span
              >
            </div>
            <div class="qianzhi_detail">
              <div class="detail_left">
                <span>客户名称：</span>
                <span>{{
                  selectedDetail.receiver ? selectedDetail.receiver.name : ""
                }}</span>
              </div>
              <div class="detail_right">
                <span>运输方式：</span>
                <div class="detail_c">
                  <div style="padding-left: 70px">
                    {{ transportsWay }}
                  </div>
                  <div>
                    <font>重量：{{ goods_weight }}</font
                    ><i></i>
                  </div>
                  <div>
                    <font>体积：{{ goods_size }}</font
                    ><i></i>
                  </div>
                  <div>
                    <font
                      >件数：{{
                        selectedDetail.goods
                          ? selectedDetail.goods.reduce((item1, item2) => {
                              return item1 + item2.number * 1;
                            }, 0)
                          : ""
                      }}</font
                    ><i></i>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button
              @click="
                dialogLabelVisible = false;
                printTime = 1;
              "
              data-tracker="P3-14"
              >取 消</el-button
            >
            <el-button
              type="primary"
              v-print="printReciptObj"
              @click="toPrintReceipt"
              data-tracker="P3-13"
              >打 印</el-button
            >
          </span>
        </el-dialog>
        <el-dialog
          title="打印面单"
          :visible.sync="dialogVisibleFaceFn"
          width="1000px"
          height="610px"
          :before-close="handleCloseFace"
          :close-on-click-modal="false"
        >
          <div
            class="facesheetContainer"
            id="printFace"
            :style="{
              'padding-right':
                toPrint === false && printType === false ? '0' : '50px',
            }"
          >
            <div class="facesheetLine1">
              <div class="line1_left">
                <div class="title">
                  <div
                    class="editTitle"
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                  >
                    <div
                      contenteditable="true"
                      style="
                        float: left;
                        font-family: 'SimSun';
                        color: #fff;
                        font-size: 27px;
                        display: inline-block;
                        height: 22px;
                        min-width: 20px;
                      "
                    ></div>
                    <div style="float: left">
                      {{ printType === false ? "渡石医药" : "" }}冷链运输详情单
                    </div>
                  </div>
                </div>
                <div class="exception">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >填写前请务必仔细阅读背书,您的签名表示您认可运输服务条款。</span
                  >
                </div>
              </div>
              <div class="line1_right">
                <div class="label1">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >条码单号</span
                  >
                </div>
                <div class="qrcode" style="margin-top: -9px">
                  <div style="height: 40px; overflow: hidden">
                    <canvas id="canvasFaceReceipt"></canvas>
                  </div>

                  <div class="waybillCode">
                    {{
                      selectedDetail.waybill_number
                        ? selectedDetail.waybill_number.slice(0, 20)
                        : ""
                    }}
                  </div>
                </div>
              </div>
            </div>
            <div class="facesheetLine2">
              <div class="line2_left">
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >寄件人姓名</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '110px',
                      'margin-left': '30px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.sender ? selectedDetail.sender.name : ''
                    "
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >始发地</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '130px',
                      'margin-left': '12px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.from_region
                        ? selectedDetail.from_region
                        : ''
                    "
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >公司名称</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '318px',
                      'margin-left': '30px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.sender ? selectedDetail.sender.company : ''
                    "
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >寄件地址</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '318px',
                      'margin-left': '30px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.sender ? selectedDetail.sender.address : ''
                    "
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >联系电话</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '318px',
                      'margin-left': '30px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.sender ? selectedDetail.sender.phone : ''
                    "
                  />
                </div>
              </div>
              <div class="line2_right">
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >收件人姓名</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '130px',
                      'margin-left': '20px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.receiver
                        ? selectedDetail.receiver.name
                        : ''
                    "
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >目的地</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '130px',
                      'margin-left': '20px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.to_region ? selectedDetail.to_region : ''
                    "
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >公司名称</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '318px',
                      'margin-left': '20px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.receiver
                        ? selectedDetail.receiver.company
                        : ''
                    "
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >收件地址</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '318px',
                      'margin-left': '20px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.receiver
                        ? selectedDetail.receiver.address
                        : ''
                    "
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >联系电话</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '318px',
                      'margin-left': '20px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.receiver
                        ? selectedDetail.receiver.phone
                        : ''
                    "
                  />
                </div>
              </div>
            </div>
            <div class="facesheetLine3">
              <div class="line3_left">
                <div class="infoLabel">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >冷链温层</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      isIncubator
                        ? selectedDetail.goods[0].thermosphere === '1'
                        : selectedDetail.thermosphere === '1'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >2~8℃</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      isIncubator
                        ? selectedDetail.goods[0].thermosphere === '2'
                        : selectedDetail.thermosphere === '2'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >-25~-15℃</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      isIncubator
                        ? selectedDetail.goods[0].thermosphere === '3'
                        : selectedDetail.thermosphere === '3'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >15~25℃</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      isIncubator
                        ? selectedDetail.goods[0].thermosphere === '7'
                        : selectedDetail.thermosphere === '7'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >-90℃~-78℃</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      isIncubator
                        ? selectedDetail.goods[0].thermosphere === '6' ||
                          selectedDetail.goods[0].thermosphere === '8' ||
                          selectedDetail.goods[0].thermosphere === '9'
                        : selectedDetail.thermosphere === '6' ||
                          selectedDetail.thermosphere === '8' ||
                          selectedDetail.thermosphere === '9'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >其它</span
                  >
                </div>
              </div>
              <div class="line3_center">
                <div class="infoLabel">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >运输信息</span
                  >
                </div>
                <span
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                  >货物品名</span
                ><input
                  type="text"
                  :style="{
                    width: '170px',
                    'margin-left': '5px',
                    'border-bottom':
                      printType === true ? '1px dashed #bebebe' : '',
                  }"
                  :value="
                    selectedDetail.goods ? selectedDetail.goods[0].name : ''
                  "
                />
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >件数</span
                  ><input
                    type="text"
                    :style="{
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.goods
                        ? selectedDetail.goods.reduce(
                            (pre, cur) => pre + cur.number * 1,
                            0
                          )
                        : ''
                    "
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >重量</span
                  ><input
                    type="text"
                    :style="{
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.goods
                        ? selectedDetail.goods.reduce(
                            (pre, cur) => pre + cur.weight / 1,
                            0
                          ) === 0
                          ? ''
                          : selectedDetail.goods.reduce(
                              (pre, cur) => pre + cur.weight / 1,
                              0
                            )
                        : ''
                    "
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >体积</span
                  ><input
                    type="text"
                    :style="{
                      width: '52px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.goods
                        ? selectedDetail.goods.reduce(
                            (pre, cur) => pre + cur.volume / 1,
                            0
                          ) === 0
                          ? ''
                          : selectedDetail.goods.reduce(
                              (pre, cur) => pre + cur.volume / 1,
                              0
                            )
                        : ''
                    "
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >保温箱型号</span
                  ><input
                    style="margin-left: 0px; width: 74px"
                    :style="{
                      'margin-left': '0px',
                      width: '74px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    type="text"
                    :value="
                      selectedDetail.goods
                        ? selectedDetail.goods.length > 1
                          ? '多个'
                          : Package_model_list.find(
                              (item) =>
                                item.item_code ===
                                selectedDetail.goods[0].package_type
                            )
                          ? Package_model_list.find(
                              (item) =>
                                item.item_code ===
                                selectedDetail.goods[0].package_type
                            ).item_name
                          : ''
                        : ''
                    "
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >温度计编号</span
                  ><input
                    type="text"
                    :style="{
                      'margin-left': '0px',
                      width: '74px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                  />
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >保温箱编号</span
                  ><input
                    type="text"
                    :style="{
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >药品批号</span
                  ><input
                    type="text"
                    :style="{
                      'margin-left': '0px',
                      width: '85px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                  />
                </div>
              </div>
              <div class="line3_right">
                <div class="infoLabel">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >运输类型</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      selectedDetail.waybill_product_type_name === '冷链零担'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >冷链零担</span
                  >
                </div>
                <div class="singleInfo">
                  <span v-if="isIncubator">√</span>
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >保温箱</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      selectedDetail.waybill_product_type_name === '冷链城配'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >冷链城配</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="selectedDetail.waybill_product_type_name === '干冰箱'"
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >干冰箱</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    v-if="
                      selectedDetail.waybill_product_type_name === '冷链整车'
                    "
                    >√</span
                  >
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >冷链整车</span
                  >
                </div>
              </div>
            </div>
            <div class="facesheetLine4">
              <div class="line4_left">
                <div class="singleInfo">
                  <span v-if="selectedDetail.insure_value === '1'">√</span>
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >投保</span
                  >
                </div>
                <div class="singleInfo" style="margin: 17px 0px 25px 25px">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >声明价值</span
                  >
                  <input
                    type="text"
                    :style="{
                      width: '45px',
                      'margin-left': '25px',
                      'border-bottom':
                        printType === true ? '1px dashed #bebebe' : '',
                    }"
                    :value="
                      selectedDetail.goods
                        ? selectedDetail.goods.reduce(
                            (pre, cur) => pre + cur.declared_value / 1,
                            0
                          ) === 0
                          ? ''
                          : selectedDetail.goods.reduce(
                              (pre, cur) => pre + cur.declared_value / 1,
                              0
                            )
                        : ''
                    "
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >元（大写）</span
                  >
                </div>
                <div class="singleInfo">
                  <span v-if="selectedDetail.insure_value === '0'">√</span>
                  <input
                    v-else
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >不投保</span
                  >
                </div>
              </div>
              <div class="line4_center">
                <div class="infoLabel">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >增值服务</span
                  >
                </div>
                <div class="singleInfo">
                  <input
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <!-- <span>√</span> -->
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >包装服务</span
                  >
                </div>
                <div class="singleInfo">
                  <input
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <!-- <span>√</span> -->
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >配送服务</span
                  >
                </div>
                <div class="singleInfo">
                  <input
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <!-- <span>√</span> -->
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >装车服务</span
                  >
                </div>
                <div class="singleInfo">
                  <input
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <!-- <span>√</span> -->
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >送仓服务</span
                  >
                </div>
                <div class="singleInfo">
                  <input
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <!-- <span>√</span> -->
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >卸车服务</span
                  >
                </div>
                <div class="singleInfo">
                  <input
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    type="checkbox"
                  />
                  <!-- <span>√</span> -->
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >重货上楼</span
                  >
                </div>
              </div>
              <div class="line4_right">
                <div class="infoLabel">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >付款方式</span
                  >
                </div>
                <div class="infoArea">
                  <div class="infoTitle">
                    <span
                      :style="{
                        visibility:
                          toPrint === false && printType === false
                            ? 'hidden'
                            : 'visible',
                      }"
                      >寄付</span
                    >
                  </div>
                  <div style="float: right; margin: 7px 5px">
                    <div class="singleInfo">
                      <span v-if="is_payment_method">√</span>
                      <input
                        v-else
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        type="checkbox"
                      />
                      <span
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        >月结</span
                      >
                    </div>
                    <div class="singleInfo">
                      <span
                        v-if="
                          selectedDetail.payment_id
                            ? selectedDetail.payment_id === '1'
                            : ''
                        "
                        >√</span
                      >
                      <input
                        v-else
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        type="checkbox"
                      />
                      <span
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        >现结</span
                      >
                    </div>
                  </div>
                </div>
                <div class="infoArea">
                  <div class="infoTitle">
                    <span
                      :style="{
                        visibility:
                          toPrint === false && printType === false
                            ? 'hidden'
                            : 'visible',
                      }"
                      >到付</span
                    >
                  </div>
                  <div style="float: right; margin: 7px 9px">
                    <div class="singleInfo">
                      <input
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        type="checkbox"
                      />
                      <!-- <span>√</span> -->
                      <span
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        >月结</span
                      >
                    </div>
                    <div class="singleInfo">
                      <input
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        type="checkbox"
                      />
                      <!-- <span>√</span> -->
                      <span
                        :style="{
                          visibility:
                            toPrint === false && printType === false
                              ? 'hidden'
                              : 'visible',
                        }"
                        >现结</span
                      >
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="facesheetLine5">
              <div class="line5">
                <div class="infoLabel">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >揽收温度</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >保温箱温度</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >车辆温度</span
                  >
                </div>
              </div>
              <div class="line5" style="float: right; width: 425px">
                <div class="infoLabel">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >配送温度</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >保温箱温度</span
                  >
                </div>
                <div class="singleInfo">
                  <span
                    :style="{
                      visibility:
                        toPrint === false && printType === false
                          ? 'hidden'
                          : 'visible',
                    }"
                    >车辆温度</span
                  >
                </div>
              </div>
            </div>
            <div class="facesheetLine6">
              <div class="line6_left1">
                <div
                  class="singleInfo"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  寄件人签名
                </div>
                <div
                  class="singleInfo"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  证件号
                </div>
                <div
                  class="singleInfo"
                  style="float: right"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  年 /&nbsp;&nbsp;月 /&nbsp;&nbsp;日 /&nbsp;&nbsp;时 /
                </div>
              </div>
              <div class="line6_left2">
                <div
                  class="singleInfo"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  揽收人签名
                </div>
              </div>
              <div class="line6_right1">
                <div
                  class="singleInfo"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  收件人签名
                </div>
                <div
                  class="singleInfo"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  证件号
                </div>
                <div
                  class="singleInfo"
                  style="float: right"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  年 /&nbsp;&nbsp;月 /&nbsp;&nbsp;日 /&nbsp;&nbsp;时 /
                </div>
              </div>
              <div class="line6_right2">
                <div
                  class="singleInfo"
                  :style="{
                    visibility:
                      toPrint === false && printType === false
                        ? 'hidden'
                        : 'visible',
                  }"
                >
                  配送人签名
                </div>
              </div>
            </div>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button
              @click="
                dialogVisibleFaceFn = false;
                toPrint = true;
                printType = false;
              "
              data-tracker="P3-16"
              >取 消</el-button
            >
            <el-button
              type="primary"
              @click="toPrintFace"
              v-print="printFaceObj"
              data-tracker="P3-15"
              >打 印</el-button
            >
          </span>
        </el-dialog>
        <!-- <el-button  v-permission="'send_company_waybill_transport_word_file'" type="primary" @click="CollectThewaybill()" plain style="margin:0px 0px 0px 10px">
            揽收运单导出
        </el-button> -->
        <el-tooltip
          class="item"
          effect="light"
          content="请先选择所属客户和承运类型(保温箱或干冰箱)在进行导出"
          placement="top"
        >
          <el-dropdown
            style="margin: 0px 0px 0px 10px"
            @command="CollectThewaybill"
          >
            <el-button type="primary" plain>
              待揽收运单导出<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown" style="width: 125px">
              <el-dropdown-item key="0" command="1">{{
                worderExName
              }}</el-dropdown-item>
              <el-dropdown-item key="1" command="2">{{
                ExcelExName
              }}</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-tooltip>

        <el-button
          type="primary"
          :loading="ztoLoading"
          @click="addZtoOrder"
          plain
          style="margin: 0px 0px 0px 10px"
        >
          中通下单
        </el-button>

        <orderPop v-if="addOrderVisible" props="addOrderVisible"></orderPop>
      </div>
      <div class="right">
        <span style="margin-right: 10px">
          <el-button
            type="primary"
            @click.stop.native
            icon="el-icon-refresh"
            @click="handleReset"
            data-tracker="P3-2"
            >重置</el-button
          >
        </span>
        <el-popover
          placement="top"
          width="570"
          v-model="visible"
          trigger="click"
        >
          <el-transfer
            ref="transfer"
            id="transfer"
            target-order="unshift"
            filterable
            :filter-method="filterMethod"
            @left-check-change="checkedChange"
            filter-placeholder="请输入字段名查询"
            :titles="['隐藏字段', '显示字段']"
            v-model="value"
            :data="data"
          >
            <span
              slot-scope="{ option }"
              class="item"
              @dragstart="drag($event, option)"
              >{{ option.label }}</span
            >
          </el-transfer>
          <div style="text-align: right; margin: 0">
            <el-button size="mini" type="text" @click="visible = false"
              >取消</el-button
            >
            <el-button type="primary" size="mini" @click="AddResultFn"
              >确定</el-button
            >
          </div>
          <el-button slot="reference"
            ><i class="el-icon-setting"></i
          ></el-button>
        </el-popover>
      </div>
    </div>
    <div v-if="HeaderData.length > 0">
      <TableHeader
        ref="TableHeaderList"
        :header_data_list="header_data_list"
        :HeaderData="HeaderData"
        :propMap="propMap"
        :objheader="objheader"
        @childEvent="handleDelete"
        @orderIdNumsEvent="handleDeleteType"
      >
      </TableHeader>
    </div>
    <div style="width: 100%; margin-top: 10px; text-align: right">
      <el-pagination
        small
        background
        :current-page="paginations.pageIndex"
        :page-sizes="paginations.pageSizes"
        :page-size="paginations.pageSize"
        :layout="paginations.layout"
        :total="paginations.total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
    <el-drawer
      title="拆单"
      size="80%"
      :visible.sync="drawer_data"
      :wrapperClosable="false"
    >
      <div v-if="drawer_data == true">
        <el-tabs type="border-card" v-model="activeName">
          <el-tab-pane label="运单1" name="first" :disabled="true">
            <disassemblyPop
              :merge_data_id="merge_data_id"
              v-on:changenext="changenext"
            ></disassemblyPop>
          </el-tab-pane>
          <el-tab-pane label="运单2" name="second" :disabled="true">
            <disassemblyPop
              :merge_data_id="merge_data_id"
              v-on:changenextsecond="changenextsecond"
              v-on:saveCode="saveCode"
            ></disassemblyPop>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-drawer>
    <el-drawer
      title="合单"
      size="80%"
      :visible.sync="merge_data"
      :wrapperClosable="false"
      ref="disassemblyPopchild"
    >
      <disassemblyPop
        :merge_data_id="merge_data_id"
        v-on:affirmMerge="affirmMerge"
      ></disassemblyPop>
    </el-drawer>
    <!-- <AddwaybillPop
      :flagShow="addflagShow"
      @parentFlagShow="DataFlagShow"
      :getWaybillListDataFn="getWaybillListDataFn"
    >
    </AddwaybillPop> -->
    <Allwaybill
      v-if="addflagShow == true"
      :id="detailid"
      :wayType="waybillType"
    ></Allwaybill>
    <EditwaybillPop
      v-if="editflagShow"
      :editflagShowData="editflagShow"
      :selectedDetail="selectedDetail"
      @EditparentFlagShow="EditFlagShowData"
      :getWaybillListDataFn="getWaybillListDataFn"
    ></EditwaybillPop>
    <Import
      :drawerData="drawerFlagShow"
      @drawerShow="drawerFlagShowFn"
    ></Import>
    <StepOperation
      mode="add"
      :showDialog="showDialog"
      :ids="selectedOrders.map(Number)"
      :step="stepCommand"
      @closeDialog="handleCloseDialog"
    ></StepOperation>
    <Importfees
      :drawerfeesData="drawerfeesFlagShow"
      @drawerfeesShow="drawerfeesFlagShowFn"
    ></Importfees>
    <ImportCollect
      :drawerCollectData="drawerCollectFlagShow"
      @drawerCollectShow="drawerCollectFlagShowFn"
    >
    </ImportCollect>
    <ImportTrunkline
      :drawertrunklineData="drawertrunklineFlagShow"
      @drawertrunklineShow="drawertrunklineFlagShowFn"
    >
    </ImportTrunkline>
    <ImportDelivery
      :drawerDeliveryData="drawerDeliveryFlagShow"
      @drawerDeliveryShow="drawerDeliveryFlagShowFn"
    >
    </ImportDelivery>
    <ImportReturnable
      :drawerReturnableData="drawerReturnableFlagShow"
      @drawerReturnableShow="drawerReturnableFlagShowFn"
    ></ImportReturnable>
    <ImportReceipt
      :drawerReceiptData="drawerReceiptFlagShow"
      @drawerReceiptShow="drawerReceiptFlagShowFn"
    >
    </ImportReceipt>
    <el-dialog
      title="揽收运单数据文件获取"
      :visible.sync="CollectVisibleewaybill"
      width="80%"
      :before-close="closeCollectThewaybill"
      center
    >
      <div style="margin: 0px 0px 10px 0px">
        <sapn>请选择所属客户：</sapn>
        <el-select
          style="width: 220px"
          filterable
          remote
          reserve-keyword
          :remote-method="searchCustomerList"
          v-model="customer_id_name"
          @change="selectedCustomer"
        >
          <el-option
            v-for="item in customerPeopleData"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
        <!-- <el-button type="primary" @click="collectTheTable()" style="margin:0px 0px 0px 10px">确定</el-button>
      <el-button type="primary" @click="resetTheTable()">清空</el-button> -->
      </div>
      <!-- <div style="margin: 0px 0px 10px 0px" v-if="customer_id_name != ''">
      <el-button type="primary" @click="wordExport()">{{worderExName }}</el-button>
      <el-button type="primary" @click="ExcelExport()">{{ ExcelExName }}</el-button>
    </div> -->
      <div v-if="customer_id_name != ''">
        <el-table
          :data="CollectwaybilltableData"
          style="width: 100%"
          @selection-change="SelectionChangewaybilling"
        >
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column prop="waybill_no" label="运单号" width="120">
          </el-table-column>
          <el-table-column
            prop="waybill_product_type_name"
            label="承运类型"
            width="100"
          >
          </el-table-column>
          <el-table-column prop="status_name" label="运单状态" width="120">
          </el-table-column>
          <el-table-column prop="customer_id_name" label="所属客户" width="140">
          </el-table-column>
          <el-table-column
            prop="thermosphere_name"
            label="运单温层"
            width="140"
          >
          </el-table-column>
          <el-table-column prop="sender_name" label="发货人"> </el-table-column>
          <el-table-column prop="sender_phone" label="发货人手机号" width="140">
          </el-table-column>
          <el-table-column prop="sender_company" label="发货公司">
          </el-table-column>
          <el-table-column prop="receiver_name" label="收货人">
          </el-table-column>
          <el-table-column
            prop="receiver_phone"
            label="收货人手机号"
            width="140"
          >
          </el-table-column>
          <el-table-column prop="receiver_company" label="收货公司" width="180">
          </el-table-column>
          <el-table-column prop="receiver_address" label="收货地址" width="180">
          </el-table-column>
          <el-table-column
            prop="goods_thermosphere_name"
            label="货物温层"
            width="120"
          >
          </el-table-column>
        </el-table>
      </div>
      <div
        style="width: 100%; margin-top: 10px; text-align: right"
        v-if="customer_id_name != ''"
      >
        <el-pagination
          @size-change="wayillhandleSizeChange"
          @current-change="wayillhandleCurrentChange"
          :current-page="wayillcurrentPage4"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="waybilall"
        >
        </el-pagination>
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button @click="closeCollectThewaybill()">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Sortable from "sortablejs";
import TableHeader from "@/page/orderform/components/TableHeader/tableheader.vue";
import {
  getWaybillListFn,
  WaybillDetailFn,
  WaybillImportFn,
  WaybillexportFn,
  WaybillDeleteFn,
  TransportDetail,
  dictionaryBatch,
  RecycleDetailFn,
  combineCreate, //确认合单
  single_details, //合单详情
  affirmDisassembly, //拆单创建
  waybillexport, //运单导出
  reqWebsiteList, //
  getTransportsList,
  dynamicHeaderList,
  dynamicHeaderCreate,
  dynamicHeaderUserList,
  getRouterList,
  reqHandlersList,
  transport_word_file,
  transport_excel_file,
  ztoRecreate,
} from "@/api/waybill";
import {
  reqPrintPageList,
  reqFieldList,
  reqPrintPageDetail,
  reqModifyPackage,
  reqZTInfo,
} from "@/api/print";
import { customerPeople } from "@/api/information";
import { organizationBox } from "@/api/organization";
// import { getLodop } from "@/utils/lodop/LodopFuncs";
import { timestamp10, downloadFile } from "@/utils/mUtils";
import otherOrderInfo from "../orderform/components/otherOrderInfo";
import buttonPage from "../../components/button/buttonPage.vue";
import AddwaybillPop from "../../components/waybillPop/Addwaybill.vue";
import Allwaybill from "../../components/waybillPop/Allwaybill.vue";
import EditwaybillPop from "../../components/waybillPop/Editwaybill.vue";
import disassemblyPop from "../waybill/components/disassembly.vue";
import Import from "../../components/waybillPop/import.vue";
import Importfees from "../../components/waybillPop/importfees.vue";
import ImportCollect from "../../components/waybillPop/ImportCollect.vue";
import ImportTrunkline from "../../components/waybillPop/ImportTrunkline.vue";
import ImportDelivery from "../../components/waybillPop/ImportDelivery.vue";
import ImportReturnable from "../../components/waybillPop/ImportReturnable.vue";
import ImportReceipt from "../../components/waybillPop/ImportReceipt.vue";
import StepOperation from "./components/stepOperation.vue";
import jsbarcode from "jsbarcode";
import logoVImg from "@/assets/img/logo.png";
// import tiaomaVImg from "@/assets/img/tiaoma.jpg";
// import smaVImg from "@/assets/img/sma.jpg";
// import titleVImg from "@/assets/img/title.jpg";
import { sendClickTracker } from "@/utils/tracker";
import { regionList } from "@/page/material/common/common";
import { dictionanryList } from "../material/common/common";
import { reqDictionaryOptions } from "@/api/earlywarning";
import { number } from "echarts";
import { isHavePermission } from "@/utils/mUtils";

export default {
  name: "waybillpage",
  components: {
    buttonPage,
    otherOrderInfo,
    AddwaybillPop,
    EditwaybillPop,
    Import,
    Importfees,
    ImportCollect,
    ImportTrunkline,
    ImportDelivery,
    ImportReturnable,
    ImportReceipt,
    StepOperation,
    disassemblyPop,
    dictionaryBatch,
    Allwaybill,
    TableHeader,
  },
  data() {
    return {
      deleteLoading: false,
      waybillType: "",
      detailid: "", //运单id
      visible: false,
      loading: false,
      numberLoding: false,
      inputVal: {},
      OpitonsData: [],
      creator_List: [], //创建人列表
      transportsType: [], //承运类型
      areaData2: [], //二级地址库
      websiteList: [], //目的网点
      sender_city_id: [], ////发货人城市
      receiver_city_id: [], //收货人公司城市
      loadingfalse: false,
      orderSearch_time: [],
      OrderstatusType: [
        {
          item_code: "0",
          item_name: "待揽收",
        },
        {
          item_code: "1",
          item_name: "揽收中",
        },
        {
          item_code: "2",
          item_name: "待创建干线",
        },
        {
          item_code: "3",
          item_name: "待发车",
        },
        {
          item_code: "4",
          item_name: "已发车",
        },
        {
          item_code: "5",
          item_name: "待配送",
        },
        {
          item_code: "6",
          item_name: "配送中",
        },
        {
          item_code: "7",
          item_name: "待签收",
        },
        {
          item_code: "8",
          item_name: "待回单",
        },
        {
          item_code: "9",
          item_name: "待回单签收",
        },
        {
          item_code: "10",
          item_name: "已完结",
        },
      ],
      payStatusList: [
        {
          id: "0",
          name: "未支付",
        },
        {
          id: "1",
          name: "已支付",
        },
        {
          id: "2",
          name: "已退款",
        },
      ],
      paymentMethodsList: [],
      activeName: "first",
      // 拆单
      drawer_data: false,
      // 拆单的数据
      waybill_list: [],
      // 合单
      merge_data: false,
      // 合单的id
      merge_data_id: "",
      logo: logoVImg,
      // tiaomaImg: tiaomaVImg,
      // smaImg: smaVImg,
      // titleImg: titleVImg,
      printTime: 1,
      dialogVisibleFaceFn: false, //打印面单
      dialogLabelVisible: false, //打印标签
      addflagShow: false,
      editflagShow: false,
      detailflagShow: false,
      drawerFlagShow: false,
      addOrderVisible: false, //这个是点击添加订单的
      selectAreaVisible: true, //这个是筛选那一行
      dialogVisible: false, //这个是打印预览的对话框
      drawerfeesFlagShow: false, // 费用导入
      drawerCollectFlagShow: false,
      drawertrunklineFlagShow: false,
      drawerDeliveryFlagShow: false,
      drawerReturnableFlagShow: false,
      drawerReceiptFlagShow: false,
      orderSearch: {
        waybill_no: "",
        status: "",
        is_over_temperature: "",
        create_time: {
          start_time: 1664553600000,
          end_time: new Date().getTime() + 3600000,
        },
        time: [1664553600000, new Date().getTime() + 3600000],
        update_time: {
          start_time: "",
          end_time: "",
        },
        sender_name: "", //发货人
        sender_phone: "", //发货人手机号
        sender_company: "", //发货公司
        receiver_name: "", //收货人
        receiver_phone: "", //收货人手机号
        receiver_company: "", //收货人公司
        to_network_id: [], //目的网点
        from_network_id: [],
        total_goods_cnt: "",
        thermosphere: "",
        waybill_product_type: "",
        creatpickerTime: "",
        updatepickerTime: "",
        from_area_id: [],
        to_area_id: [],
        customer_id: "",
        creator_id: "", //创建人
        customerList: [], //所属客户
        customer_area_id: "", //客户区域
        status_list: [],
        // from_network_name:[],
        // to_network_name:[],
        // total_goods_cnt: "",
        // thermosphere: "",
        //waybillVal: "",
        // creatpickerTime: "",
        // updatepickerTime: "",
        payment: "",
        pay_status: "",
      },
      options: [
        {
          value: "",
          label: "全部",
        },
        {
          value: "1",
          label: "超温",
        },
        {
          value: "2",
          label: "即将超温",
        },
        {
          value: "0",
          label: "正常",
        },
      ],
      pickerOptions: {
        // 时间选择器的快选项
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      orders: [],
      selectedOrders: [], // 选中id list
      selectedDetail: {},
      steps: [
        {
          id: "1",
          value: "揽收",
        },
        {
          id: "2",
          value: "干线",
        },
        {
          id: "3",
          value: "配送",
        },
        {
          id: "4",
          value: "签收",
        },
        {
          id: "5",
          value: "回单",
        },
        {
          id: "6",
          value: "回箱",
        },
      ],
      showDialog: false, // 运单流程弹框展示
      stepCommand: "",
      paginations: {
        pageIndex: 1, // 当前位于哪页
        pageSize: 20, // 1页显示多少条
        pageSizes: [10, 20, 50, 100], //每页显示多少条
        total: 0,
        layout: "total, sizes, prev, pager, next, jumper", // 翻页属性
      },
      transportsWayList: [], //运输方式
      transportsWay: "",
      goods_weight: 0,
      goods_size: 0,
      //commodity_number: 0,
      goodsName: "",
      maxheight: 400,
      thermosphereData: "",
      numberItem: 1,
      printReciptObj: {
        id: "#printMe",
      },
      Package_model_list: [],
      is_payment_method: false,
      toPrint: true, //false是不显示背景
      printFaceObj: {
        id: "printFace",
        beforeOpenCallback(vue) {
          this.toPrint = false;
          vue.printLoading = true;
        },
      },
      printType: false, //false是通用,true是吉因加
      printPageList: [], //打印用的模板列表
      LODOP: {},
      titleStr: "",
      mainlyStr: "",
      toPrintStr: "",
      thermosphereData: {},
      HeaderData: [],
      data: [],
      value: [], //右边一列的值
      filterMethod(query, item) {
        return item.pinyin.indexOf(query) > -1;
      },
      draggingKey: "",
      menuFilterMethod(query, item) {
        // return item.menuListdata.indexOf(query) > -1
        const regStr = query.replace(/\*/g, ".*");
        const reg = new RegExp(regStr);
        return reg.test(item.label);
      },
      waybillNumber: "",
      codesData: [],
      organizationBoxData: [],
      fromnetworknameData: [],
      tonetworknameData: [],
      propsBranchType: {
        emitPath: true,
        checkStrictly: true,
        value: "id",
        label: "branch_name",
        children: "next_level_data",
      },
      customerPeopleData: [],
      websiteListDQ: [],
      ISrejectSign: [
        {
          id: "0",
          value: "否",
        },
        {
          id: "1",
          value: "是",
        },
      ],
      header_data_list: [],
      header_data_item_list: [],
      propMap: {},
      obj_list: {},
      isIncubator: false,
      exportdata: {},
      dialogTableVisible: false,
      multipleSelection: [],
      CollectVisibleewaybill: false,
      customer_id_name: "",
      CollectwaybilltableData: [],
      waybindList: [],
      worderExName: "word导出(全部)",
      ExcelExName: "Excel导出(全部)",
      waybilpage: 1,
      waybilpage_size: 10,
      waybilall: 0,
      wayillcurrentPage4: 1,
      ztoLoading: false,
    };
  },
  mounted() {
    this.provincectiy(); //地址库
    this.getWebsiteList(); //目的网点
    this.getThermosphereType(); //承运类型
    this.getDictionary(); // 温度区间
    this.Pagecreator(); //获取员工
    // this.getOrderstatusTypeFn();
    this.searchCustomerList();
    this.organizationBoxFn();
    this.SelectOpitonsFn();
    this.getWebsiteListDQFn();
    this.getThermosphereTypeFn();
    this.dynamicHeaderListFn();
    const transfer = this.$refs.transfer.$el;
    const leftPanel = transfer
      .getElementsByClassName("el-transfer-panel")[0]
      .getElementsByClassName("el-transfer-panel__body")[0];
    const rightPanel = transfer
      .getElementsByClassName("el-transfer-panel")[1]
      .getElementsByClassName("el-transfer-panel__body")[0];
    const rightEl = rightPanel.getElementsByClassName(
      "el-transfer-panel__list"
    )[0];
    Sortable.create(rightEl, {
      animation: 100,
      onEnd: (evt) => {
        const { oldIndex, newIndex } = evt;
        const temp = this.value[oldIndex];
        if (!temp || temp === "undefined") {
          return;
        }
        for (var i = 0; i < this.value.length; i++) {
          if (
            this.value[i] === "" ||
            this.value[i] === null ||
            typeof this.value[i] === "undefined"
          ) {
            this.value.splice(i, 1);
            i = i - 1;
          }
        }
        const arr_temp = [].concat(this.value); // 创建一个新的临时数组，用以操作后不变更原数组
        arr_temp.splice(newIndex, 0, arr_temp.splice(oldIndex, 1)[0]); // 在b位置插入从a位置截取的元素
        this.value = arr_temp;

        this.$emit("update:call-back", this.value);
      },
    });
    const leftEl = leftPanel.getElementsByClassName(
      "el-transfer-panel__list"
    )[0];
    Sortable.create(leftEl, {
      animation: 100,
      onEnd: (evt) => {
        const { oldIndex, newIndex } = evt;
        const temp = this.datas[oldIndex];
        this.$set(this.datas, oldIndex, this.datas[newIndex]);
        this.$set(this.datas, newIndex, temp);
      },
    });
    leftPanel.ondragover = (ev) => {
      ev.preventDefault();
    };
    leftPanel.ondrop = (ev) => {
      ev.preventDefault();
      const index = this.value.indexOf(this.draggingKey);
      if (index !== -1) {
        this.value.splice(ev, 1);
      }
    };
    rightPanel.ondragover = (ev) => {
      ev.preventDefault();
    };
    rightPanel.ondrop = (ev) => {
      ev.preventDefault();
      if (this.value.indexOf(this.draggingKey) === -1) {
        this.value.push(this.draggingKey);
      }
    };
  },
  computed: {
    isDushi() {
      const id = JSON.parse(
        localStorage.getItem("user" || "{}")
      ).saas_company_id;
      return id === 1;
    },
  },
  methods: {
    //获取订单状态
    // getOrderstatusTypeFn() {
    //   dictionaryBatch({ codes: ["waybill_status"] }).then((res) => {
    //     if (res.code === 10000) {
    //       this.OrderstatusType = res.data.list.waybill_status;
    //       // console.log(this.OrderstatusType, '运单状态')
    //     }
    //   });
    // },
    isHavePermission(val) {
      return isHavePermission(val);
    },
    // 用户列表接口
    Pagecreator() {
      reqHandlersList().then((res) => {
        this.creator_List = res.data;
      });
    },
    //获取区域
    async getWebsiteListDQFn() {
      let result = await reqWebsiteList({ branch_type: "3" });
      this.websiteListDQ = result.data;
    },
    //获取所属客户
    searchCustomerList(query) {
      //获取客户
      if (query !== "") {
        setTimeout(async () => {
          // let { router, router_id } = this.formData;
          let result = await customerPeople({
            name: query, // 名称
            id: "",
            is_send: "1",
            is_receive: "",
          });
          if (result.data.length > 0) {
            this.customerPeopleData = result.data;
          } else {
            this.customerPeopleData = [];
          }
        }, 200);
      } else {
        this.customerPeopleData = [];
      }
    },
    //获取级联组织架构
    organizationBoxFn() {
      let data = {
        show_employee: false, // 是否展示员工信息
        not_show_first_branch: 1,
      };
      organizationBox(data).then((res) => {
        if (res.code === 10000) {
          this.organizationBoxData = res.data;
        }
      });
    },
    //获取温层
    getThermosphereTypeFn() {
      dictionaryBatch({ codes: ["thermosphere", "pay_way"] }).then((res) => {
        if (res.code === 10000) {
          this.codesData = res.data.list.thermosphere;
          this.paymentMethodsList = res.data.list.pay_way;
        }
      });
    },
    SelectOpitonsFn() {
      const data = {
        dictionary_code: "order_status",
      };
      reqDictionaryOptions(data).then((res) => {
        if (res.code === 10000 || res.data.list.length > 0) {
          this.OpitonsData = res.data.list;
        }
      });
    },
    //左侧列表数据
    checkedChange(val) {},
    //过滤项
    //始发网点过滤
    fromnetworkname(val) {
      this.fromnetworknameData = val;
      this.getWaybillListDataFn();
    },
    tonetworkname(val) {
      this.tonetworknameData = val;
      this.getWaybillListDataFn();
    },
    changeValue() {
      this.getWaybillListDataFn();
    },
    updatepickerTime(val) {
      if (val) {
        this.orderSearch.update_time.start_time = timestamp10(val[0]);
        this.orderSearch.update_time.end_time = timestamp10(val[1]);
      } else {
        this.orderSearch.update_time.start_time = "";
        this.orderSearch.update_time.end_time = "";
      }
      this.getWaybillListDataFn();
    },
    creatpickerTime(val) {
      if (val) {
        this.orderSearch.create_time.start_time = timestamp10(val[0]);
        this.orderSearch.create_time.end_time = timestamp10(val[1]);
      } else {
        this.orderSearch.create_time.start_time = "";
        this.orderSearch.create_time.end_time = "";
      }
      this.getWaybillListDataFn();
    },
    thermosphereChange(val) {
      this.getWaybillListDataFn();
    },
    waybillTypeChange(val) {
      this.getWaybillListDataFn();
    },
    customerChange() {
      this.getWaybillListDataFn();
    },
    fromareaChange() {
      this.getWaybillListDataFn();
    },
    toareaChange() {
      this.getWaybillListDataFn();
    },
    creatortypeChange() {
      this.getWaybillListDataFn();
    },
    creatorChange() {
      this.getWaybillListDataFn();
    },
    statusChange() {
      this.getWaybillListDataFn();
    },
    //获取自定义表头字段
    AddResultFn() {
      let rightData;
      rightData = this.data.filter((item) => this.value.includes(item.key));
      let arritemsdata = rightData.map((element, index) => {
        return {
          id: element.key + "",
          sequence: rightData.length - this.value.indexOf(element.key) + "",
        };
      });
      let dataObj = {
        header_id: this.waybillNumber + "",
        items_data: arritemsdata,
      };
      dynamicHeaderCreate(dataObj).then((res) => {
        if (res.code === 10000) {
          this.dynamicHeaderUserListFn();
          this.getWaybillListDataFn();
        }
      });
    },
    //获取模块ID 函数
    dynamicHeaderListFn() {
      const data = {};
      dynamicHeaderList(data).then((res) => {
        if (res.code === 10000) {
          res.data.list.forEach((element) => {
            if (element.name == "waybill") {
              this.waybillNumber = element.id;
              // this.dynamicHeaderItemsListFn();
              this.getWaybillListDataFn();
              this.dynamicHeaderUserListFn();
            }
          });
        }
      });
    },
    // 用户设定表头字段（显示字段）
    dynamicHeaderUserListFn() {
      let data = {
        header_id: this.waybillNumber + "",
      };
      dynamicHeaderUserList(data).then((res) => {
        if (res.code === 10000) {
          let showData = [];
          let idData = [];
          res.data.select_items == null
            ? []
            : res.data.select_items.forEach((val, index) => {
                showData.push({
                  label: val.title,
                  key: val.id,
                  pinyin: val.title,
                });
              });
          this.data = showData;
          res.data.un_selected_items == null
            ? []
            : res.data.un_selected_items.forEach((val, index) => {
                showData.push({
                  label: val.title,
                  key: val.id,
                  pinyin: val.title,
                });
              });
          this.data = showData;
          res.data.select_items == null
            ? []
            : res.data.select_items.forEach((val, index) => {
                idData.push(val.id);
              });
          this.value = idData;
        }
      });
    },
    // 承运类型
    async getThermosphereType() {
      let result2 = await getTransportsList({ is_all: false });
      this.transportsType = result2.data.data;
    },
    getDictionary() {
      dictionanryList(["thermosphere"]).then((res) => {
        const data = res.data.list["thermosphere"];
        data.forEach((item) => {
          const { item_code, item_name } = item;
          this.thermosphereData[item_code] = item_name;
        });
      });
    },
    // 地址库
    provincectiy() {
      regionList(0).then((res) => {
        this.childeprovicectiy(res.data);
      });
    },
    // 地址库改为二级
    childeprovicectiy(data) {
      data.forEach((item) => {
        item.next_level_data.forEach((iten) => {
          iten.next_level_data = undefined;
        });
      });
      this.areaData2 = data;
    },
    async getWebsiteList() {
      let result = await reqWebsiteList({ type: "0" });
      this.websiteList = result.data;
    },
    // 运单导出
    ExportOrders() {
      this.loadingfalse = true;
      var data = {
        ids: this.selectedOrders.map(Number),
        ...this.exportdata,
        // sender_city_id:
        //   this.sender_city_id[1] == "undefined" ? 0 : this.sender_city_id[1],
        // receiver_city_id:
        //   this.receiver_city_id[1] == "undefined"
        //     ? 0
        //     : this.receiver_city_id[1],
        // header_id: this.waybillNumber + "",
        // thermosphere: this.orderSearch.thermosphere,
        // total_goods_cnt: this.orderSearch.total_goods_cnt,
        // ...this.orderSearch,
        // waybill_product_type: this.orderSearch.waybill_product_type.map(Number),
        // create_time: {
        //   start_time: (this.orderSearch.create_time.start_time + "").slice(
        //     0,
        //     10
        //   ),
        //   end_time: (this.orderSearch.create_time.end_time + "").slice(0, 10),
        // },
        // update_time: {
        //   start_time: this.orderSearch.update_time.start_time,
        //   end_time: this.orderSearch.update_time.end_time,
        // },
        // customer_id: this.orderSearch.customer_id + "",
        // creator_id: this.orderSearch.creator_id * 1, //创建人
        // from_network_id_list:
        //   this.orderSearch.from_network_id != ""
        //     ? [
        //         this.orderSearch.from_network_id[
        //           this.orderSearch.from_network_id.length - 1
        //         ],
        //       ]
        //     : [],
        // to_network_id_list:
        //   this.orderSearch.to_network_id != ""
        //     ? [
        //         this.orderSearch.to_network_id[
        //           this.orderSearch.to_network_id.length - 1obj_list
        //         ],
        //       ]
        //     : [],
        // from_network_id: "",
        // to_network_id: "",
        // from_area_id: this.orderSearch.from_area_id + "",
        // to_area_id: this.orderSearch.to_area_id + "",
        // customer_area_id: this.orderSearch.customer_area_id + "",
        // status_list: this.orderSearch.status_list.map((item) => {
        //   return item * 1;
        // }),
        // from_network_name: "",
        // to_network_name: "",
        // creatpickerTime: "",
        // updatepickerTime: "",
      };
      waybillexport(data).then((res) => {
        if (res.code === 10000) {
          this.reqUrl = "https://" + res.data.loaded_url;
          window.open(this.reqUrl);
          this.loadingfalse = false;
        }
      });
    },
    async handlePrint() {
      //点击选中某个打印模板之后
      let module = await import("@/utils/lodop/LodopFuncs");
      module.getLodop();
      if (this.printPageList.length === 0) {
        let result = await reqPrintPageList({});
        this.printPageList = result.data.list.filter(
          (item) => item.template_data.template_name !== "保温箱标签"
        );
      }
    },
    async printWaybills(e) {
      let module = await import("@/utils/lodop/LodopFuncs");
      // module.getLodop();
      //循环生成打印代码的函数,用于批量打印
      let joinStr;
      let splitStr;
      let sliceStr;
      let waybillStr = [];
      this.selectedOrders.forEach(async (waybill, waybillIndex) => {
        let fieldDetail;
        let pageDetail;
        let result1 = await reqFieldList({ waybill_id: waybill * 1 });
        fieldDetail = result1.data;
        let pushArr = [];
        //将多余的单选框选项与应该出现的值加到数组里面
        fieldDetail.forEach((item, index) => {
          if (item.chinese_name === "承运产品类型") {
            if (item.value === "保温箱") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "baowenxiang",
                  value: "√",
                },
                {
                  chinese_name: "冷链零担",
                  value: "",
                },
                {
                  chinese_name: "冷链整车",
                  value: "",
                },
                {
                  chinese_name: "ganbingxiang",
                  value: "",
                },
              ]);
            } else if (item.value === "干冰箱") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "ganbingxiang",
                  value: "√",
                },
                {
                  chinese_name: "冷链零担",
                  value: "",
                },
                {
                  chinese_name: "冷链整车",
                  value: "",
                },
                {
                  chinese_name: "baowenxiang",
                  value: "",
                },
              ]);
            }
            if (item.value === "冷链零担") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "冷链零担",
                  value: "√",
                },
                {
                  chinese_name: "baowenxiang",
                  value: "",
                },
                {
                  chinese_name: "冷链整车",
                  value: "",
                },
                {
                  chinese_name: "ganbingxiang",
                  value: "",
                },
              ]);
            } else if (item.value === "冷链整车") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "冷链整车",
                  value: "√",
                },
                {
                  chinese_name: "baowenxiang",
                  value: "",
                },
                {
                  chinese_name: "冷链零担",
                  value: "",
                },
                {
                  chinese_name: "ganbingxiang",
                  value: "",
                },
              ]);
            } else {
              pushArr = pushArr.concat([
                {
                  chinese_name: "冷链零担",
                  value: "",
                },
                {
                  chinese_name: "baowenxiang",
                  value: "",
                },
                {
                  chinese_name: "冷链整车",
                  value: "",
                },
                {
                  chinese_name: "ganbingxiang",
                  value: "",
                },
              ]);
            }
          } else if (item.chinese_name === "是否投保") {
            if (item.value === "是") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "是",
                  value: "√",
                },
                {
                  chinese_name: "否",
                  value: "",
                },
              ]);
            } else if (item.value === "否") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "否",
                  value: "√",
                },
                {
                  chinese_name: "是",
                  value: "",
                },
              ]);
            }
          } else if (item.chinese_name === "付款方式") {
            if (item.value === "月结" || item.value === " 月结") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "月结",
                  value: "√",
                },
                {
                  chinese_name: "现付",
                  value: "",
                },
              ]);
            } else if (item.value === "现付") {
              pushArr = pushArr.concat([
                {
                  chinese_name: "现付",
                  value: "√",
                },
                {
                  chinese_name: "月结",
                  value: "",
                },
              ]);
            } else {
              pushArr = pushArr.concat([
                {
                  chinese_name: "现付",
                  value: "",
                },
                {
                  chinese_name: "月结",
                  value: "",
                },
              ]);
            }
          } else if (item.chinese_name === "温层") {
            if (
              this.printPageList
                .find((item) => item.id === e)
                .template_data.template_name.indexOf("标签") === -1
            ) {
              if (item.value === "-25℃以下") {
                pushArr = pushArr.concat([
                  {
                    chinese_name: "-25℃以下",
                    value: "√",
                  },
                  {
                    chinese_name: "0- 30℃",
                    value: "",
                  },
                  {
                    chinese_name: "-60~-90℃",
                    value: "",
                  },
                  {
                    chinese_name: "15~25℃",
                    value: "",
                  },
                  {
                    chinese_name: "2~8℃",
                    value: "",
                  },
                  {
                    chinese_name: "-15~-25℃",
                    value: "",
                  },
                  {
                    chinese_name: "otherThermosphere",
                    value: item.value,
                  },
                ]);
              } else if (item.value === "0- 30℃") {
                pushArr = pushArr.concat([
                  {
                    chinese_name: "0- 30℃",
                    value: "√",
                  },
                  {
                    chinese_name: "-25℃以下",
                    value: "",
                  },
                  {
                    chinese_name: "-60~-90℃",
                    value: "",
                  },
                  {
                    chinese_name: "15~25℃",
                    value: "",
                  },
                  {
                    chinese_name: "2~8℃",
                    value: "",
                  },
                  {
                    chinese_name: "-15~-25℃",
                    value: "",
                  },
                  {
                    chinese_name: "otherThermosphere",
                    value: item.value,
                  },
                ]);
              } else if (item.value === "-60~-90℃") {
                pushArr = pushArr.concat([
                  {
                    chinese_name: "-60~-90℃",
                    value: "√",
                  },
                  {
                    chinese_name: "-25℃以下",
                    value: "",
                  },
                  {
                    chinese_name: "0- 30℃",
                    value: "",
                  },
                  {
                    chinese_name: "15~25℃",
                    value: "",
                  },
                  {
                    chinese_name: "2~8℃",
                    value: "",
                  },
                  {
                    chinese_name: "-15~-25℃",
                    value: "",
                  },
                  {
                    chinese_name: "otherThermosphere",
                    value: "",
                  },
                ]);
              } else if (item.value === "15~25℃") {
                pushArr = pushArr.concat([
                  {
                    chinese_name: "15~25℃",
                    value: "√",
                  },
                  {
                    chinese_name: "-25℃以下",
                    value: "",
                  },
                  {
                    chinese_name: "-60~-90℃",
                    value: "",
                  },
                  {
                    chinese_name: "0- 30℃",
                    value: "",
                  },
                  {
                    chinese_name: "2~8℃",
                    value: "",
                  },
                  {
                    chinese_name: "-15~-25℃",
                    value: "",
                  },
                  {
                    chinese_name: "otherThermosphere",
                    value: "",
                  },
                ]);
              } else if (item.value === "2~8℃") {
                pushArr = pushArr.concat([
                  {
                    chinese_name: "2~8℃",
                    value: "√",
                  },
                  {
                    chinese_name: "-25℃以下",
                    value: "",
                  },
                  {
                    chinese_name: "-60~-90℃",
                    value: "",
                  },
                  {
                    chinese_name: "15~25℃",
                    value: "",
                  },
                  {
                    chinese_name: "0- 30℃",
                    value: "",
                  },
                  {
                    chinese_name: "-15~-25℃",
                    value: "",
                  },
                  {
                    chinese_name: "otherThermosphere",
                    value: "",
                  },
                ]);
              } else if (item.value === "-15~-25℃") {
                pushArr = pushArr.concat([
                  {
                    chinese_name: "-15~-25℃",
                    value: "√",
                  },
                  {
                    chinese_name: "-25℃以下",
                    value: "",
                  },
                  {
                    chinese_name: "-60~-90℃",
                    value: "",
                  },
                  {
                    chinese_name: "15~25℃",
                    value: "",
                  },
                  {
                    chinese_name: "2~8℃",
                    value: "",
                  },
                  {
                    chinese_name: "0- 30℃",
                    value: "",
                  },
                  {
                    chinese_name: "otherThermosphere",
                    value: "",
                  },
                ]);
              } else {
                pushArr = pushArr.concat([
                  {
                    chinese_name: "-15~-25℃",
                    value: "",
                  },
                  {
                    chinese_name: "-25℃以下",
                    value: "",
                  },
                  {
                    chinese_name: "-60~-90℃",
                    value: "",
                  },
                  {
                    chinese_name: "15~25℃",
                    value: "",
                  },
                  {
                    chinese_name: "2~8℃",
                    value: "",
                  },
                  {
                    chinese_name: "0- 30℃",
                    value: "√",
                  },
                  {
                    chinese_name: "otherThermosphere",
                    value: item.value,
                  },
                ]);
              }
            }
          } else if (item.chinese_name === "收货人姓名") {
            pushArr.push({
              chinese_name: item.chinese_name,
              value: item.value,
            });
          } else if (item.chinese_name === "包装数量") {
            pushArr.push(
              {
                chinese_name: item.chinese_name,
                value: item.value,
              },
              {
                chinese_name: item.chinese_name,
                value: item.value,
              }
            );
          } else if (item.chinese_name === "运单号") {
            pushArr.push({
              chinese_name: "yundanhao",
              value: item.value,
            });
          }
        });
        fieldDetail = fieldDetail.concat(pushArr);
        let result2 = await reqPrintPageDetail({
          id: e, //这个是模板的id
        });
        pageDetail = result2.data.template_data.template_design;
        this.LODOP = module.getLodop();
        fieldDetail.forEach((item) => {
          item.value = item.value.replace(/\s*/g, "");
          pageDetail = pageDetail.replace(item.chinese_name, item.value);
        });
        if (
          this.printPageList
            .find((item) => item.id === e)
            .template_data.template_name.indexOf("标签") === -1
        ) {
          //非标签打印时每份内容都一样
          splitStr = JSON.parse(pageDetail).split(";");
          // splitStr.pop();
          this.titleStr = splitStr.slice(0, 2); //最开始init的那几行
          sliceStr = splitStr.slice(2);
          sliceStr.splice(sliceStr.length - 1, 0, "\r\nLODOP.NewPage()"); //加一行
          sliceStr.pop(); //删除最后的换行符
          waybillStr = waybillStr.concat(sliceStr);
          // joinStr = waybillStr.join(";");
          this.mainlyStr = waybillStr;
        } else {
          //标签打印时需要每打一份就加一下
          let goodsValue =
            fieldDetail.find((item) => item.chinese_name === "包装数量").value *
            1;
          for (var goodsIndex = 0; goodsIndex < goodsValue; goodsIndex++) {
            let detailAdd = pageDetail.replace(/number/g, goodsIndex + 1);
            splitStr = JSON.parse(detailAdd).split(";");
            this.titleStr = splitStr.slice(0, 2); //最开始init的那几行
            sliceStr = splitStr.slice(2);
            sliceStr.splice(sliceStr.length - 1, 0, "\r\nLODOP.NewPage()"); //加一行
            sliceStr.pop(); //删除最后的换行符
            waybillStr = waybillStr.concat(sliceStr);
            // joinStr = waybillStr.join(";");
            this.mainlyStr = waybillStr;
          }
        }
      });
      setTimeout(() => {
        this.toPrintStr =
          this.titleStr.join(";") + this.mainlyStr.join(";").slice(0, -15);
      }, 1500);
    },
    async getZTOPrintInfo(e) {
      //  let result = await reqZTInfo({
      //   order_no: this.multipleSelection[0].order_no,
      // });
      let module = await import("@/utils/lodop/LodopFuncs");
      // module.getLodop();
      //循环生成打印代码的函数,用于批量打印
      let joinStr;
      let splitStr;
      let sliceStr;
      let waybillStr = [];
      let ztoresult = await reqZTInfo({
        order_no: this.multipleSelection[0].order_no,
      });
      if (ztoresult.code !== 10000) return;
      ztoresult.data.forEach(async (ztoItem) => {
        let fieldDetail;
        let pageDetail;
        fieldDetail = ztoItem;
        let result2 = await reqPrintPageDetail({
          id: e, //这个是模板的id
        });
        pageDetail = result2.data.template_data.template_design;
        this.LODOP = module.getLodop();
        fieldDetail.forEach((item) => {
          if (item["chinese_name"] === "printedName") {
            item.value = JSON.parse(localStorage.getItem("user")).nickname;
          }
          if (item["chinese_name"] === "qrCode") {
            //不然识别不出来JSON
            item.value = item.value.replace(/"/g, "'");
          }
          pageDetail = pageDetail.replace(item.chinese_name, item.value);
        });
        console.log(pageDetail, "pageDetail");
        //非标签打印时每份内容都一样
        splitStr = JSON.parse(pageDetail).split(";");
        // splitStr.pop();
        this.titleStr = splitStr.slice(0, 2); //最开始init的那几行
        sliceStr = splitStr.slice(2);
        sliceStr.splice(sliceStr.length - 1, 0, "\r\nLODOP.NewPage()"); //加一行
        sliceStr.pop(); //删除最后的换行符
        waybillStr = waybillStr.concat(sliceStr);
        // joinStr = waybillStr.join(";");
        this.mainlyStr = waybillStr;
      });
      setTimeout(() => {
        this.toPrintStr =
          this.titleStr.join(";") + this.mainlyStr.join(";").slice(0, -15);
      }, 1500);
    },
    nextToPrint(e, flag) {
      let that = this;
      if (flag === "zto") {
        this.getZTOPrintInfo(e);
      } else {
        this.printWaybills(e);
      }
      if (this.toPrintStr) {
        setTimeout(() => {
          eval(this.toPrintStr);
          LODOP.PRINT_DESIGN();
          // LODOP.PREVIEW();
        }, 2000);
      } else {
        setTimeout(() => {
          eval(this.toPrintStr);
          LODOP.PRINT_DESIGN();
          // LODOP.PREVIEW();
        }, 3000);
      }
      if (LODOP.CVERSION)
        CLODOP.On_Return = function (TaskID, Value) {
          if (that.toPrintStr) {
            that.toPrintStr = "";
            that.titleStr = "";
            that.mainlyStr = "";
          } else {
          }
        };
    },
    async submitPackageNum() {
      let result = await reqModifyPackage({
        items: this.multipleSelection.map((item) => {
          return {
            waybill_id: item.id,
            incubator_count: item.total_package_quantity,
          };
        }),
      });
      if (result.code !== 10000) {
        this.$message({
          type: "error",
          message: result.message,
        });
        return;
      }
      this.dialogTableVisible = false;
      this.nextToPrint(
        this.printPageList.find(
          (item) => item.template_data.template_name == "标签"
        ).id
      );
      this.$message({
        type: "success",
        message: "提交成功,加载中......",
      });
    },
    selectPrintPage(e) {
      if (this.multipleSelection.length >= 1) {
        if (
          this.printPageList
            .find((item) => item.id == e)
            .template_data.template_name.indexOf("中通") !== -1
        ) {
          this.nextToPrint(e, "zto");
          return;
        }
        if (
          this.printPageList.find((item) => item.id == e).template_data
            .template_name == "标签"
        ) {
          if (
            this.multipleSelection.filter((item) => item.status > 2).length !==
            0
          ) {
            this.$message({
              type: "warning",
              message: "只有待揽收或揽收中的运单可以打印标签",
            });
            return;
          }
          this.dialogTableVisible = true;
          return;
        }
        this.nextToPrint(e);
      } else {
        this.$message({
          type: "warning",
          message: "至少选择一个运单",
        });
      }
      sendClickTracker("P3-43");
    },
    // 揽收时间变化
    handleDateChange(val) {
      if (val) {
        this.orderSearch.create_time.start_time = timestamp10(val[0]);
        this.orderSearch.create_time.end_time = timestamp10(val[1]);
      } else {
        this.orderSearch.create_time.start_time = "";
        this.orderSearch.create_time.end_time = "";
      }
    },
    rowStyle({ row }) {
      let jsonObj = {};
      // if (row.is_over_temperature && row.is_over_temperature === "1") {
      //   jsonObj.background = "#ffc4c4 !important";
      //   return jsonObj;
      // }
      /**
       * 20221206新逻辑 添加即将超温 预警支持显示颜色自定义
       */
      if (row.show_color) {
        jsonObj.background = `${row.show_color} !important`;
        return jsonObj;
      } else {
        return "";
      }
    },
    async getWaybillListDataFn() {
      this.loading = true;
      let _this = this;
      setTimeout(() => {
        _this.numberLoding = true;
      }, 50);
      var param = {
        page: this.paginations.pageIndex, //1
        page_size: this.paginations.pageSize, //100
        header_id: this.waybillNumber + "",
        create_time: {
          start_time: (this.orderSearch.create_time.start_time + "").slice(
            0,
            10
          ),
          end_time: (this.orderSearch.create_time.end_time + "").slice(0, 10),
        },
        ...this.obj_list,
      };
      this.exportdata = param;
      let result = await getWaybillListFn(param);
      this.orders = result.data.data == null ? [] : result.data.data;
      this.orders.unshift({});
      this.loading = false;
      this.numberLoding = true;
      this.header_data_list = result.data.data;
      this.HeaderData = result.data.item_list;
      this.Fntransformation(this.HeaderData);
      this.paginations.total = result.data.total;
    },
    objheader(obj) {
      var data = {
        header_id: this.waybillNumber + "",
        ...obj,
      };
      this.obj_list = { ...obj };
      this.exportdata = obj;
      getWaybillListFn(data).then((res) => {
        this.header_data_list = res.data.data;
        if (res.code === 10000 && res.data.data !== null) {
          this.header_data_list.unshift({});
          this.paginations.total = res.data.total;
          this.paginations.pageSize = res.data.page_size;
          this.paginations.pageIndex = res.data.page;
        } else {
          this.header_data_list = [{}];
          this.paginations.total = res.data.total;
        }
      });
    },
    handleDelete(index, id, type) {
      // this.detailid = id.id
      // this.waybillType = "onlyread"
      // this.addflagShow = type
      // // console.log(index,id,type)
      // // console.log(index,id,type,"fjalksdfjl")
      this.handleJump(id);
    },
    handleDeleteType(value) {
      console.log(value, "fjalsjfdl");
      this.handleSelectionChange(value);
      this.selectedOrders = value;
    },
    // 隐射函数
    Fntransformation(obj) {
      const result = {};
      for (const prop in obj) {
        if (obj.hasOwnProperty(prop)) {
          if (obj[prop].send_name !== "") {
            result[obj[prop].name] = obj[prop].show_name;
          } else {
            result[obj[prop].name] = obj[prop].name;
          }
        }
      }
      this.propMap = result;
    },
    handleSelectionChange(checked) {
      let arr = [];
      checked.forEach((item, index) => {
        let obj = this.header_data_list.filter((data) => data.id * 1 == item);
        if (obj) arr[index] = obj[0];
        console.log(arr, "this.multipleSelection");
      });
      this.selectedOrders = checked.map((item) => item.id);
      this.multipleSelection = arr;
    },
    //运单添加点击按钮函数
    WaybillClickFn() {
      this.waybillType = "add";
      this.addflagShow = true;
    },
    WaybillClose() {
      this.addflagShow = false;
      this.getWaybillListDataFn();
    },
    //控制运单弹出框显示关闭
    DataFlagShow(data) {
      // this.addflagShow = data;
    },

    //编辑运单点击函数
    async clickEditPropFn() {
      if (this.selectedOrders.length === 1) {
        this.detailid = this.selectedOrders[0];
        this.waybillType = "onlyread";
        this.addflagShow = true;
      } else if (this.selectedOrders.length > 1) {
        this.$message({
          type: "warning",
          message: "只能同时编辑一个运单，请刷新重试",
        });
      } else {
        this.$message({
          type: "warning",
          message: "至少选择一个运单",
        });
      }
    },

    //点击编辑弹出窗关闭控制函数
    EditFlagShowData(data) {
      this.editflagShow = data;
    },

    // 点击然后展示运单详情 功能函数
    clickDetailFn() {
      detailflagShow = true;
    },

    //导入函数
    toLead() {
      this.drawerFlagShow = true;
    },

    async handleJump(scope) {
      const checkedOrder = scope;
      const { id } = checkedOrder;
      let text = this.$router.resolve({
        name: "waybillDetail",
        query: { id },
      });
      window.open(text.href, "_blank");
    },
    handleCloseDialog() {
      this.showDialog = false;
      this.getWaybillListDataFn();
    },
    handleCommand(command) {
      if (this.selectedOrders.length === 0) {
        this.$message({
          message: "选中运单后可继续进行操作",
          type: "error",
        });
      } else {
        this.stepCommand = command;
        this.showDialog = true;
        const codes = ["", "P3-7", "P3-8", "P3-9", "P3-10", "P3-11", "P3-12"];
        sendClickTracker(codes[command]);
      }
    },
    handleWaybill(val) {
      const Fn = ["toLead", , "openPrintLabel", "openFaceReceipt"][val];
      this[Fn] && this[Fn]();
      let tracker = "";
      if (val == "4") {
        this.tear_down(4);
        tracker = "P3-34";
      } else if (val == "5") {
        this.tear_down(5);
        tracker = "P3-35";
      } else if (val == "6") {
        this.printJYJ();
        tracker = "P3-36";
      }
      sendClickTracker(tracker);
    },
    handleWaybillMessage(val) {
      const Fn = ["toLeadMessage"][val];
      this[Fn] && this[Fn]();
      if (val == "1") {
        this.toLeadMessage();
      } else if (val == "2") {
        this.drawerCollect();
      } else if (val == "3") {
        this.drawertrunkline();
      } else if (val == "4") {
        this.drawerDelivery();
      } else if (val == "5") {
        this.drawerReceipt();
      } else if (val == "6") {
        this.drawerReturnable();
      }
      const codes = ["", "P3-37", "P3-38", "P3-39", "P3-40", "P3-41", "P3-42"];
      sendClickTracker(codes[val]);
    },
    toLeadMessage() {
      this.drawerfeesFlagShow = true;
    },
    //控制导入是否显示函数
    drawerfeesFlagShowFn(data) {
      this.drawerfeesFlagShow = data;
    },
    //提货费用修改
    drawerCollect() {
      this.drawerCollectFlagShow = true;
    },
    drawerCollectFlagShowFn(data) {
      this.drawerCollectFlagShow = data;
    },
    //干线费用修改
    drawertrunkline() {
      this.drawertrunklineFlagShow = true;
    },
    drawertrunklineFlagShowFn(data) {
      this.drawertrunklineFlagShow = data;
    },
    //配送费用修改
    drawerDelivery() {
      this.drawerDeliveryFlagShow = true;
    },
    drawerDeliveryFlagShowFn(data) {
      this.drawerDeliveryFlagShow = data;
    },
    //回箱费用修改导入
    drawerReturnable() {
      this.drawerReturnableFlagShow = true;
    },
    drawerReturnableFlagShowFn(data) {
      this.drawerReturnableFlagShow = data;
    },
    //回单费用修改导入
    drawerReceipt() {
      this.drawerReceiptFlagShow = true;
    },
    drawerReceiptFlagShowFn(data) {
      this.drawerReceiptFlagShow = data;
    },
    printJYJ() {
      this.printType = true;
      this.openFaceReceipt();
    },
    //拆单合单函数判断 4 拆单 5 合单
    tear_down(val) {
      switch (val) {
        case 4:
          if (this.selectedOrders.length == "0") {
            this.$message({
              message: "请选择一个运单",
              type: "warning",
            });
          } else if (this.selectedOrders.length == "1") {
            // 当一弹出弹框状态为first
            var data_matter = {
              id: this.selectedOrders[0],
              disabled: "4",
              tabsname: "first",
            };
            this.activeName = "first";
            this.merge_data_id = data_matter;
            this.waybill_list = [];
            this.drawer_data = true;
          } else {
            this.$message({
              message: "最多能选择一个运单",
              type: "warning",
            });
          }
          break;
        case 5:
          if (this.selectedOrders.length == "0") {
            this.$message({
              message: "请选择运单",
              type: "warning",
            });
          } else if (this.selectedOrders.length == "1") {
            this.$message({
              message: "至少选择两个运单",
              type: "warning",
            });
          } else {
            var selecteOrders_id = this.selectedOrders.map(Number);
            var param = {
              waybill_id_list: selecteOrders_id,
            };
            single_details(param).then((res) => {
              if (res != undefined) {
                if (res.code == "10000") {
                  this.merge_data = true;
                  var data_matter = {
                    id: selecteOrders_id,
                    disabled: "5",
                  };
                  this.merge_data_id = data_matter;
                }
              } else {
              }
            });
          }
          break;
      }
    },
    affirmMerge(data) {
      data.waybill_id_list = this.selectedOrders.map(Number);
      combineCreate(data).then((res) => {
        if (res.code == "10000") {
          this.$message({
            message: "合单成功",
            type: "success",
          });
          this.merge_data = false;
          this.getWaybillListDataFn();
        }
      });
    },
    // 拆单下一步
    changenext(data) {
      this.activeName = data.name;
      this.merge_data_id = {
        id: this.selectedOrders[0],
        disabled: "4",
        tabsname: data.name,
      };
      this.waybill_list.push(data.waybill_list);
    },
    // 拆单上一步
    changenextsecond(data) {
      this.activeName = data.name;
      this.merge_data_id = {
        id: this.selectedOrders[0],
        disabled: "4",
        tabsname: data.name,
      };
      this.waybill_list = [];
    },
    // 保存数据
    saveCode(data) {
      if (this.waybill_list.length == "1") {
        this.waybill_list.push(data.waybill_list);
        var param = {
          waybill_id: this.selectedOrders[0],
          waybill_list: this.waybill_list,
        };
        this.affirmDisassemblyPage(param);
      } else if (this.waybill_list.length >= "2") {
        this.waybill_list.pop();
        this.waybill_list.push(data.waybill_list);
        var param = {
          waybill_id: this.selectedOrders[0],
          waybill_list: this.waybill_list,
        };
        this.affirmDisassemblyPage(param);
      }
    },
    // 拆单接口
    affirmDisassemblyPage(val) {
      affirmDisassembly(val).then((res) => {
        if (res.code == "10000") {
          this.$message({
            message: "拆单成功",
            type: "success",
          });
          this.drawer_data = false;
          this.getWaybillListDataFn();
        }
      });
    },
    //控制导入是否显示函数
    drawerFlagShowFn(data) {
      this.drawerFlagShow = data;
    },

    //导出函数
    ClickWaybillexportFn() {
      WaybillexportFn().then((res) => {
        // console.log(res, "这是运单列表导出函数");
      });
    },

    // 删除运单操作函数 code_id 为运单唯一标识 id
    ClickDeleteFn() {
      this.deleteLoading = true;
      const params = {
        ids: this.selectedOrders.map((item) => item * 1),
      };
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          WaybillDeleteFn(params).then((res) => {
            if (res && res.code === 10000) {
              this.$message({
                type: "success",
                message: "删除成功!",
              });
              this.deleteLoading = false;
              this.getWaybillListDataFn();
            } else {
              this.deleteLoading = false;
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
          this.deleteLoading = false;
        });
    },
    // 每页条数改变
    handleSizeChange(val) {
      this.paginations.pageSize = val;
      this.getWaybillListDataFn();
    },
    // 当前页改变
    handleCurrentChange(val) {
      this.paginations.pageIndex = val;
      this.getWaybillListDataFn();
    },
    handleSearch() {
      this.paginations.pageIndex = 1;
      this.getWaybillListDataFn();
    },
    handleReset() {
      this.orderSearch = {
        create_time: {
          start_time: 1664553600000,
          end_time: new Date().getTime(),
        },
      };

      this.$refs.TableHeaderList.childMethod();
      this.paginations.pageIndex = 1;
      this.getWaybillListDataFn();
    },
    showSelectArea() {
      this.selectAreaVisible = !this.selectAreaVisible;
    },
    async openPrintLabel() {
      if (this.selectedOrders.length === 1) {
        let id = this.selectedOrders[0] + "";
        let result = await WaybillDetailFn({ id });
        this.selectedDetail = result.data;
        this.selectedDetail.goods.forEach((item) => {
          this.goods_weight += item.weight * 1;
        });
        this.goods_weight = parseFloat(this.goods_weight).toFixed(3);
        this.selectedDetail.goods.forEach((item) => {
          this.goods_size += item.volume * 1;
        });
        this.goods_size = parseFloat(this.goods_size).toFixed(3);
        let result1 = await dictionaryBatch({
          codes: ["transport_way", "thermosphere"],
        });
        if (this.selectedDetail.waybill_product_type_name === "保温箱") {
          let idData = this.selectedDetail.goods[0].thermosphere;
          this.thermosphereData = result1.data.list.thermosphere.find(
            (item) => {
              return item.item_code === idData;
            }
          ).item_name;
        } else if (
          this.selectedDetail.waybill_product_type_name === "常温零担"
        ) {
          this.thermosphereData = "";
        } else if (
          this.selectedDetail.waybill_product_type_name === "常温整车"
        ) {
          this.thermosphereData = "";
        } else if (
          this.selectedDetail.waybill_product_type_name === "冷链零担"
        ) {
          if (this.selectedDetail.thermosphere !== "0") {
            let idData = this.selectedDetail.thermosphere;
            this.thermosphereData = result1.data.list.thermosphere.find(
              (item) => {
                return item.item_code === idData;
              }
            ).item_name;
          } else {
            this.thermosphereData = "";
          }
        } else if (
          this.selectedDetail.waybill_product_type_name === "冷链整车"
        ) {
          if (this.selectedDetail.thermosphere !== "0") {
            let idData = this.selectedDetail.thermosphere;
            this.thermosphereData = result1.data.list.thermosphere.find(
              (item) => {
                return item.item_code === idData;
              }
            ).item_name;
          } else {
            this.thermosphereData = "";
          }
        } else {
          this.thermosphereData = "";
        }
        this.transportsWayList = result1.data.list.transport_way;
        this.transportsWay = this.transportsWayList.find(
          (item) => item.item_code == this.selectedDetail.transport_days
        ).item_name;
        setTimeout(() => {
          jsbarcode("#canvas", this.selectedDetail.waybill_number, {
            lineColor: "#000",
            width: 2.5,
            height: 40,
            displayValue: false,
          });
        }, 400);
        this.dialogLabelVisible = true;
      } else if (this.selectedOrders.length > 1) {
        this.$message({
          type: "warning",
          message: "只能同时打印一个运单",
        });
      } else {
        this.$message({
          type: "warning",
          message: "至少选择一个运单",
        });
      }
    },
    toPrintReceipt() {
      setTimeout(() => {
        this.numberItem++;
      }, 800);
    },
    toPrintFace() {
      this.toPrint = false;
    },
    async openFaceReceipt() {
      if (this.selectedOrders.length === 1) {
        let id = this.selectedOrders[0] + "";
        let result2 = await dictionaryBatch({
          codes: ["Package_model"],
        });
        this.Package_model_list = result2.data.list.Package_model;
        let result = await WaybillDetailFn({ id });
        this.selectedDetail = result.data;
        this.isIncubator =
          this.selectedDetail.waybill_product_business_type === "1";
        this.is_payment_method = this.selectedDetail.payment_id === "4";
        this.selectedDetail.goods.forEach((item) => {
          this.goodsName = this.goodsName + item.name + ", ";
        });
        setTimeout(() => {
          jsbarcode(
            "#canvasFaceReceipt",
            this.selectedDetail.waybill_number.slice(0, 20),
            {
              lineColor: "#000",
              width: 1, //每小条的宽度
              height: 60, //总条码的宽度
              displayValue: false,
            }
          );
        }, 400);
        this.dialogVisibleFaceFn = true;
      } else if (this.selectedOrders.length > 1) {
        this.$message({
          type: "warning",
          message: "只能同时打印一个运单",
        });
      } else {
        this.$message({
          type: "warning",
          message: "至少选择一个运单",
        });
      }
    },
    handleClose() {
      this.dialogLabelVisible = false;
    },
    handleCloseFace() {
      this.dialogVisibleFaceFn = false;
    },
    selectable(row, index) {
      if (index === 0) {
        return false;
      } else {
        return true;
      }
    },
    submitForm() {
      this.handleSearch();
    },
    titleFocus() {
      this.collClick = this.$refs.coll.setActiveNames;
      this.$refs.coll.setActiveNames = () => {};
    },
    titleBlur() {
      this.$refs.coll.setActiveNames = this.collClick;
    },
    CollectThewaybill(val) {
      if (val == 1) {
        this.wordExport();
      } else if (val == 2) {
        this.ExcelExport();
      }
    },
    closeCollectThewaybill() {
      this.CollectVisibleewaybill = false;
      this.resetTheTable();
    },
    selectedCustomer(id) {
      this.customer_id_name = id;
      this.collectTheTable();
    },
    addZtoOrder() {
      if (this.selectedOrders.length === 0) {
        this.$message({
          type: "warning",
          message: "至少选择一个运单",
        });
        return;
      }
      this.ztoLoading = true;
      ztoRecreate({
        waybill_ids: this.selectedOrders.map(Number),
      }).then((res) => {
        this.ztoLoading = false;

        if (res.code === 10000) {
          this.$message({
            type: "success",
            message: "中通下单成功",
          });
        } else {
          this.$message({
            type: "warning",
            message: res.message,
          });
        }
      });
    },
    collectTheTable() {
      if (this.customer_id_name != "") {
        var param = {
          status_list: [0],
          customer_id: this.customer_id_name + "",
          waybill_product_type: [15, 27],
          page: this.waybilpage,
          page_size: this.waybilpage_size,
        };
        getWaybillListFn(param).then((res) => {
          if (res.code == 10000) {
            console.log(res.data.data);
            this.CollectwaybilltableData = res.data.data;
            this.waybilall = res.data.total;
          }
        });
      } else {
        this.waringObj();
      }
    },
    resetTheTable() {
      this.customer_id_name = "";
      this.CollectwaybilltableData = [];
      this.waybilpage = 1;
      this.waybilpage_size = 10;
      this.waybilall = 0;
    },
    SelectionChangewaybilling(value) {
      this.waybindList = value.map((item) => item.id);
      if (this.waybindList.length > 0) {
        this.worderExName = "word导出(选中)";
        this.ExcelExName = "Excel导出(选中)";
      } else {
        this.worderExName = "word导出(全部)";
        this.ExcelExName = "Excel导出(全部)";
      }
    },
    // 导出word
    wordExport() {
      if (this.obj_list.customer_id != undefined) {
          var param = {
            customer_id: this.obj_list.customer_id * 1,
            waybill_ids: this.selectedOrders.map(Number),
          };
          transport_word_file(param).then((res) => {
            console.log(res.data.data,"resresresres")
            if (res.code == 10000) {
             if(res.data.data != ""){
              var reqUrl = res.data.data + "";
              downloadFile(`待揽收运单导出`, reqUrl);
             }else {
              this.$message({
                showClose: true,
                message: "当前客户暂无待揽收运单",
                type: "warning",
              });
             }
           
            }
          });
      } else {
        this.waringObj();
      }
    },
    // 导出Excle
    ExcelExport() {
      if (this.obj_list.customer_id != undefined) {
          var param = {
            customer_id: this.obj_list.customer_id * 1,
            waybill_ids: this.selectedOrders.map(Number),
          };
          transport_excel_file(param).then((res) => {
            if (res.code == 10000) {
              if(res.data.data != "") {
                var reqUrl = "https://" + res.data.data;
              window.open(reqUrl, "_blank");
              }else {
                this.$message({
                showClose: true,
                message: "当前客户暂无待揽收运单",
                type: "warning",
              });
              }
            }
          });
      } else {
        this.waringObj();
      }
    },
    // waring警告
    waringObj() {
      this.$message({
        showClose: true,
        message: "请先选择所属客户",
        type: "warning",
      });
    },
    wayillhandleSizeChange(val) {
      this.waybilpage_size = val;
      this.collectTheTable();
      console.log(`每页 ${val} 条`);
    },
    wayillhandleCurrentChange(val) {
      this.waybilpage = val;
      this.collectTheTable();
      console.log(`当前页: ${val}`);
    },
    // TypeOFcarriage() {
    //   var Typeof = false;
    //   console.log(this.obj_list.waybill_product_type);
    //   if (this.obj_list.waybill_product_type != undefined) {
    //     if (
    //       this.obj_list.waybill_product_type.includes(15) ||
    //       this.obj_list.waybill_product_type.includes(27)
    //     ) {
    //       Typeof = true;
    //       console.log(Typeof, "Typeof");
    //     } else if (!this.obj_list.waybill_product_type.includes(15)) {
    //       this.$message({
    //         showClose: true,
    //         message: "承运类型请选择保温箱",
    //         type: "warning",
    //       });
    //       Typeof = false;
    //     } else if (!this.obj_list.waybill_product_type.includes(27)) {
    //       this.$message({
    //         showClose: true,
    //         message: "承运类型请选择干冰箱",
    //         type: "warning",
    //       });
    //       Typeof = false;
    //     } else {
    //       this.$message({
    //         showClose: true,
    //         message: "承运类型请选择保温箱和干冰箱",
    //         type: "warning",
    //       });
    //       Typeof = false;
    //     }
    //   } else {
    //     this.$message({
    //       showClose: true,
    //       message: "承运类型请选择保温箱和干冰箱",
    //       type: "warning",
    //     });
    //     Typeof = false;
    //   }
    //   return Typeof;
    // },
  },
};
</script>

<style scoped lang="less">
/deep/.qianzhi_content .el-checkbox__label {
  color: #000 !important;
}

// /deep/.el-dialog__body {
//   padding: 0px !important;
// }

// /deep/.el-dialog__header {
//   display: none !important;
// }

/deep/.el-table td.el-table__cell .el-tooltip div span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.allOrderContainer {
  .orderHeader {
    background-color: #fff;

    .orderSearch {
      ::v-deep .el-form--inline .el-form-item__content {
        vertical-align: middle;
      }

      ::v-deep .el-collapse {
        border-top: none;
        border-bottom: none;
      }
    }
  }

  .actions {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
    background-color: #fff;

    .el-button + .el-dropdown,
    .el-dropdown + .el-button,
    .el-dropdown + .el-dropdown {
      margin-left: 10px;
    }
  }

  .footer {
    font-size: 12px;
    font-weight: bold;
    position: fixed;
    bottom: 0;
    background-color: #e9e9e9;
    width: 100%;
    height: 28px;
    line-height: 28px;
    z-index: 2;
  }

  .operation-drop {
    .drop-item {
      width: 200px;
    }
  }
}

.qianzhi_content {
  width: 475px;
  height: 460px;
  overflow: hidden;
  border: 1px dashed #000;

  .qianzhi_top {
    height: 50px;
    overflow: hidden;
    border-bottom: 1px dashed #000;

    .top_left {
      font-size: 24px;
      color: #000;
      float: left;
      font-weight: bold;
      line-height: 45px;
      padding-left: 10px;

      img {
        width: 50px;
        height: 50px;
        float: left;
        margin-right: 10px;
      }
    }

    .top_right {
      float: right;
      text-align: center;
      margin-right: 30px;
      margin-top: 3px;

      span {
        font-size: 18px;
        font-weight: bold;
        display: block;
      }

      i {
        font-size: 12px;
        margin-top: -3px;
        display: block;
      }
    }
  }

  .qianzhi_tm {
    height: 80px;
    border-bottom: 1px dashed #000;

    img {
      width: 493px;
      height: 80px;
    }
  }

  .qianzhi_address {
    height: 30px;
    overflow: hidden;
    border-bottom: 1px dashed #000;

    span {
      display: block;
      float: left;
      height: 30px;
      line-height: 30px;
      padding-left: 5px;
    }

    .span1 {
      width: 90px;
      text-align: center;
      display: block;
      border-right: 1px dashed #000;
    }
  }

  .qianzhi_sjr {
    height: 100px;
    overflow: hidden;
    border-bottom: 1px dashed #000;

    span {
      display: block;
      float: left;

      i {
        display: block;
        line-height: 25px;
        padding-left: 5px;
      }
    }

    .span2 {
      width: 26px;
      padding: 21px 22px 22px 47px;
      border-right: 1px dashed #000;
    }
  }

  .shangj_code {
    height: 30px;
    overflow: hidden;
    border-bottom: 1px dashed #000;

    span {
      display: block;
      float: left;
      height: 30px;
      line-height: 30px;
      padding-left: 25px;
      margin-right: 10px;
    }

    .span1 {
      width: 208px;
      text-align: left;
      display: block;
      border-right: 1px dashed #000;
    }
  }

  .qianzhi_detail {
    min-height: 200px;

    .detail_left {
      width: 49%;
      float: left;
      display: block;
      min-height: 200px;
      border-right: 1px dashed #000;

      span {
        display: block;
        width: 100%;
        height: 30px;
        line-height: 30px;
        padding-left: 25px;
      }
    }

    .detail_right {
      width: 50.5%;
      float: left;
      display: block;
      min-height: 200px;

      span {
        display: block;
        width: 100%;
        height: 30px;
        line-height: 30px;
        padding-left: 5px;
      }

      .detail_c {
        overflow: hidden;

        div {
          width: 100%;
          height: 33px;
          line-height: 33px;
          border-bottom: 1px dashed #000;

          span {
            display: block;
            float: left;
            width: 28%;
            text-align: center;
            height: 20px;
            line-height: 20px;
          }

          font {
            display: block;
            float: left;
            padding-left: 5px;
          }

          i {
            display: block;
            float: left;
          }
        }
      }
    }
  }
}

.facesheetContainer {
  width: 910px;
  height: 576px;
  background-color: #fd7c45;

  div,
  span {
    font-family: "SimSun";
    font-size: 12px;
  }

  .facesheetLine1 {
    height: 29px;
    padding-top: 20px;
    margin-left: 50px;

    .line1_left {
      float: left;
      margin-top: -15px;

      .title {
        color: white;
        // margin: 5px 0;
        margin-left: 225px;

        .editTitle {
          overflow: hidden;
        }

        div {
          font-size: 27px;
        }
      }

      .exception {
        font-size: 10px;
        -webkit-transform: scale(0.9);
        margin-left: -5px;
      }
    }

    .line1_right {
      overflow: hidden;
      float: right;
      // width: 189px;
      height: 50px;
      margin-top: -20px;
      background-color: #fff;

      .label1 {
        box-sizing: border-box;
        width: 37px;
        height: 57px;
        line-height: 20px;
        padding: 5px 12px;
        padding-right: 0px;
        font-size: 14px;
        display: inline-block;
      }

      .qrcode {
        float: right;

        .waybillCode {
          margin-left: 10px;
          margin-top: -2px;
          font-size: 15px;
          letter-spacing: 1.5px;
        }
      }
    }
  }

  .facesheetLine2 {
    margin-left: 50px;
    margin-top: 3px;
    height: 110px;

    .line2_left {
      float: left;
      width: 421px;
      height: 110px;
      background-color: #fff;

      .singleInfo {
        margin: 8px 12px;
      }
    }

    .line2_right {
      float: right;
      width: 426px;
      height: 110px;
      background-color: #fff;

      .singleInfo {
        margin: 8px 10px;
      }
    }
  }

  .facesheetLine3 {
    margin-left: 50px;
    margin-top: 5px;
    height: 100px;
    display: flex;
    justify-content: space-between;

    .line3_left {
      width: 288px;
      height: 100px;
      background-color: #fff;

      .infoLabel {
        font-size: 14px;
        font-weight: bold;
        display: block;
        margin: 3px 18px;
      }

      .singleInfo {
        margin: 6px 30px;
        margin-right: 5px;
        display: inline-block;
        width: 100px;
      }
    }

    .line3_center {
      width: 294px;
      height: 100px;
      background-color: #fff;

      .infoLabel {
        font-size: 14px;
        display: inline-block;
        font-weight: bold;
        margin: 2px 10px;
      }

      .singleInfo {
        margin: 6px 10px;

        input {
          width: 47px;
          margin-left: 15px;
        }
      }
    }

    .line3_right {
      width: 250px;
      height: 100px;
      background-color: #fff;

      .infoLabel {
        font-size: 14px;
        font-weight: bold;
        display: block;
        margin: 3px 10px;
      }

      .singleInfo {
        margin: 6px 10px;
        display: inline-block;
        width: 100px;
      }
    }
  }

  .facesheetLine4 {
    margin-left: 50px;
    margin-top: 8px;
    height: 110px;
    display: flex;
    justify-content: space-between;

    .line4_left {
      width: 203px;
      height: 110px;
      background-color: #fff;

      .singleInfo {
        margin: 7px 30px;
      }
    }

    .line4_center {
      width: 204px;
      height: 110px;
      background-color: #fff;

      .infoLabel {
        font-size: 14px;
        font-weight: bold;
        display: block;
        margin: 7px 10px;
      }

      .singleInfo {
        margin: 4px 10px;
        display: inline-block;
        width: 76px;
      }
    }

    .line4_right {
      width: 425px;
      height: 110px;
      background-color: #fff;

      .infoLabel {
        font-size: 14px;
        font-weight: bold;
        display: block;
        margin: 4px 15px;
      }

      .infoArea {
        display: inline-block;
        width: 40%;

        .infoTitle {
          display: inline-block;
          margin-left: 55px;
          margin-top: 30px;
        }

        .singleInfo {
          margin: 7px 15px;
        }
      }
    }
  }

  .facesheetLine5 {
    margin-left: 50px;
    margin-top: 8px;
    height: 93px;

    .line5 {
      float: left;
      width: 425px;
      height: 93px;
      background-color: #fff;

      .infoLabel {
        font-size: 14px;
        font-weight: bold;
        display: block;
        margin: 4px 10px;
      }

      .singleInfo {
        margin: 17px 10px;
      }
    }
  }

  .facesheetLine6 {
    margin-left: 50px;
    margin-top: 8px;
    height: 81px;
    display: flex;
    justify-content: space-between;

    .line6_left1 {
      width: 210px;
      height: 81px;
      background-color: #fff;

      .singleInfo {
        margin: 10px 10px;
      }
    }

    .line6_left2 {
      width: 202px;
      height: 81px;
      background-color: #fff;

      .singleInfo {
        margin: 10px 10px;
      }
    }

    .line6_right1 {
      width: 210px;
      height: 81px;
      background-color: #fff;

      .singleInfo {
        margin: 10px 10px;
      }
    }

    .line6_right2 {
      width: 202px;
      height: 81px;
      background-color: #fff;

      .singleInfo {
        margin: 10px 10px;
      }
    }
  }
}
</style>